#ifndef DEVICESSPI_H_
#define DEVICESSPI_H_


extern SPI_HandleTypeDef g_SPI2Handle;


#define SPI2_NSS_ENABLE() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET)
#define SPI2_NSS_DISABLE() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET)


void vSPI2Init(void);

int8_t cSPIWriteDatas(SPI_HandleTypeDef *hSPIHand, uint8_t *pBuffer, int32_t iLength);
int8_t cSPIWriteByte(SPI_HandleTypeDef *hSPIHand, uint8_t ucByte);
int8_t cSPIReadDatas(SPI_HandleTypeDef *hSPIHand, uint8_t *pBuffer, int32_t iLength);
int8_t cSPIReadByte(SPI_HandleTypeDef *hSPIHand, uint8_t *pucByte);

#define cSPI2WriteDatas(pBuffer, iLength)  cSPIWriteDatas(&g_SPI2Handle, (pBuffer), (iLength))
#define cSPI2WriteByte(ucByte)              cSPIWriteByte(&g_SPI2Handle, (ucByte))
#define cSPI2ReadDatas(pBuffer, iLength)   cSPIReadDatas(&g_SPI2Handle, (pBuffer), (iLength))
#define cSPI2ReadByte(pucByte)              cSPIReadByte(&g_SPI2Handle, (pucByte))


#endif /* DEVICESSPI_H_ */
